<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
<link href="../template/css/main.css" rel="stylesheet" type="text/css">
<link href="../template/css/meun.css" rel="stylesheet" type="text/css"/>
<div class="bg">
<div class="left_topnav">当前用户:${userBean.gftUserInfo.userName}</div>
<div class="leftsidebar">菜单列表</div>
<div class="left_topnav">
<script type="text/javascript">
function PhenItem(id, pid, label, url, type, img, over, img2, over2, title, target) {
    this.id = id;
    this.pid = pid;
    this.label = label;
    this.url = url;
    this.title = title;
    this.target = "work_spaces";
    this.img = img;
    this.over = over;
    this.img2 = img2;
    this.over2 = over2;
    this.type = type;
    //this._ih = false;	//is it the head item?
    this._hc = false;
    //has the child item?
    this._ls = false;
    //has sibling item?
    this._io = false;
    //whether the panelbar is open?
};
//menu object
function PhenMenu(objName) {
    this.config = {
        closeSameLevel : false
    };
    //alert("asdsdf");
    this.obj = objName;
    this.items = [];
    this.root = new PhenItem(-1);
};
//add a new item to the item array
PhenMenu.prototype.add = function(id, pid, label, url, type, img, over, img2, over2, title, target) {
    this.items[this.items.length] = new PhenItem(id, pid, label, url, type, img, over, img2, over2, title, target);
};
// Outputs the menu to the page
PhenMenu.prototype.toString = function() {
    //alert("arrived here");
    var str = '<div>\n';
    if (document.getElementById) {
        str += this.addItem(this.root);
    } else str += 'Browser not supported.';
    str += '\n</div>';
    //alert(str);
    //document.write(str);
    //alert(this.items[0]._hc);
    return str;
};
// Creates the menu structure
PhenMenu.prototype.addItem = function(pItem) {
    var str = '';
    //var n=0;
    for (var n = 0; n < this.items.length; n++) {
        if (this.items[n].pid == pItem.id) {
            var ci = this.items[n];
            //alert(ci.pid);
            //alert(ci.id);
            this.setHS(ci);
            //alert("item:"+ci._hc);
            //alert(ci._ls);
            str += this.itemCreate(ci, n);
            if (ci._ls) break;
        }
    }
    return str;
};
// Creates the node icon, url and text
PhenMenu.prototype.itemCreate = function(pItem, itemId) {
    //alert(pItem.type.toLowerCase());
    var str = '';
    if (pItem.type == 'header')
        str = '<table width="100%" class="header" valign="middle" onmouseover="this.className=\'headerSelected\'" onmouseout="this.className=\'header\'" onclick="' + this.obj + '.o(' + itemId + ')"><tr><td>';
    else
        str = '<table width="100%" class="item" valign="middle" onmouseover="this.className=\'itemOver\'" onmouseout="this.className=\'item\'" onclick="' + this.obj + '.o(' + itemId + ')"><tr><td>';
    if (pItem.img) {
        str += '&nbsp;&nbsp;<img id="i' + this.obj + itemId + '" src="' + pItem.img + '" alt="" />';
    }
    if (pItem.url) {
        str += '<a id="s' + this.obj + itemId + '" class="navigation_item" href="' + pItem.url + '"';
        if (pItem.title) str += ' title="' + pItem.title + '"';
        if (pItem.target) str += ' target="' + pItem.target + '"';
        str += ' onmouseover="window.status=\'' + pItem.label + '\';return true;" onmouseout="window.status=\'\';return true;"';
        str += '>';
    }
    str += '&nbsp;&nbsp;&nbsp;&nbsp;' + pItem.label;
    if (pItem.url) str += '</a>';
    str += '</td></tr></table>';
    //alert(pItem.url);
    //alert(str);
    if (pItem._hc) {
        str += '<table id="ct' + this.obj + itemId + '" width="100%" style="display:' + ((pItem._io) ? 'block' : 'none') + '; FILTER: blendTrans(Duration=1.0); VISIBILITY: hidden"><tr><td>';
        str += this.addItem(pItem);
        str += '</td></tr></table>';
        //alert(str);
        //document.write(str);
    }
    return str;
};
// Checks whether a item has child and if it is the last sibling
PhenMenu.prototype.setHS = function(pItem) {
    var lastId;
    for (var n = 0; n < this.items.length; n++) {
        if (this.items[n].pid == pItem.id) pItem._hc = true;
        if (this.items[n].pid == pItem.pid) lastId = this.items[n].id;
    }
    if (lastId == pItem.id) pItem._ls = true;
};
// Toggle Open or close
PhenMenu.prototype.o = function(id) {
    //alert(this.items.length);
    var ci = this.items[id];
    //alert(ci);
    //this.setHS(ci);
    //alert(this.items[id]._hc);
    this.itemStatus(!ci._io, id);
    ci._io = !ci._io;
    if (this.config.closeSameLevel) this.closeLevel(ci);
};
// Change the status of a item(open or closed)
PhenMenu.prototype.itemStatus = function(status, id) {
		try{
		    cTable = document.getElementById('ct' + this.obj + id);
		    if (status) {
		        //cTable.filters.item(0).Apply();
		        
		        cTable.style.display = 'block';
		         cTable.style.visibility = "";
		        
		        //cTable.filters.item(0).Play();
		    }
		    else
		        cTable.style.display = 'none';
        }catch(ex){}
    //cDiv.style.display = (status) ? 'block': 'none';
};
// Closes all items on the same level as certain item
PhenMenu.prototype.closeLevel = function(pItem) {
    //alert(this.items[0]._hc);
    for (var n = 0; n < this.items.length; n++) {
        //alert(this.items[n]._hc);
        if ((this.items[n].pid == pItem.pid) && (this.items[n].id != pItem.id) && this.items[n]._hc) {
            this.itemStatus(false, n);
            this.items[n]._io = false;
            this.closeAllChildren(this.items[n]);
        }
    }
};
PhenMenu.prototype.closeAllChildren = function(pItem) {
    for (var n = 0; n < this.items.length; n++) {
        if (this.items[n].pid == pItem.id && this.items[n]._hc) {
            if (this.items[n]._io) this.itemStatus(false, n);
            this.items[n]._io = false;
            this.closeAllChildren(this.items[n]);
        }
    }
};
	<!-- 资源权限菜单 -->
    <c:set var="userType" scope="page" value="${userBean.gftUserInfo.userType}" /> // 1: admin
    <%--<c:out value="${userType}" />--%>
    <c:set var="rightMap" scope="page" value="${userBean.gftRightMap}" />
    p = new PhenMenu('p');
    <c:if test="${userType == 1 || not empty rightMap.GFTUSERMANAGE.rightName || not empty rightMap.GFTROLEMANAGE.rightName || not empty rightMap.GFTRIGHTMANAGE.rightName}">
    p.add(0, -1, '系统管理', '', 'header', '../template/images/an_2.gif');
    </c:if>
    <c:if test="${userType == 1 || not empty rightMap.GFTUSERMANAGE.rightName}">
    p.add(1, 0, '用户管理', '${pageContext.request.contextPath}/gftuser.x?op=findUser');
    </c:if>
    <c:if test="${userType == 1 || not empty rightMap.GFTROLEMANAGE.rightName}">
    p.add(2, 0, '角色管理', '${pageContext.request.contextPath}/gftuser.x?op=findRole');
    </c:if>
    <c:if test="${userType == 1 || not empty rightMap.GFTRIGHTMANAGE.rightName}">
    p.add(3, 0, '权限管理', '${pageContext.request.contextPath}/gftuser.x?op=findRight');
    </c:if>
    <c:if test="${userType == 1 || not empty rightMap.GFTRIGHTCONFIGURE.rightName}">
    p.add(4,0,'权限配置','${pageContext.request.contextPath}/rightsettings.x?op=find');
    </c:if>
    <c:if test="${userType == 1 || not empty rightMap.SYSRELOAD.rightName}">
    p.add(5, -1, '运行信息', '', 'header', '../template/images/an_2.gif');
    p.add(1, 5, '系统重载', '${pageContext.request.contextPath}/system.x?op=go&go=reLoad');
    </c:if>
    <!--  应用菜单  -->
    
    <c:if test="${userType == 2 && not empty rightMap.SALARYLIST.rightName}">
    p.add(6, -1, '用户菜单', '', 'header', '../template/images/an_2.gif');
    p.add(1, 6, '列表', '${pageContext.request.contextPath}/salary.x?op=page');
    </c:if>
    

    
    
    document.write(p);
</script>
</div>
</div>